package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"time"
)

func main() {
	filePath := "text.txt"
	str := bytes.NewBufferString("hello world\n")
	file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_APPEND, 0666)

	if err != nil {
		fmt.Println("open file err=", err)
		return
	}

	defer file.Close()
	//str := "let's go\n"
	//写入5句话
	writer := bufio.NewWriter(file)
	for i := 0; i < 5; i++ {
		writer.WriteString(str.String())
	}
	//把缓冲区的文件正在写入到路径文件中
	writer.Flush()
	fmt.Println(time.Unix(0, 566))
}
